import pygame
from .. import constants as C
from . import coin
from .. import setup,tools
pygame.font.init()

class Info:
    def __init__(self,state):
        self.state=state
        self.createStateLables()
        self.createInfoLables()
        self.flash_coin=coin.idleCoin()

    def createStateLables(self):
        self.stateLabels=[]
        if self.state=='mainMenu':
            self.stateLabels.append((self.createLabel('1 PLAYER GAME'),(272,360)))
            self.stateLabels.append((self.createLabel('2 PLAYER GAME'),(272,405)))
            self.stateLabels.append((self.createLabel('TOP -'),(290,465)))
            self.stateLabels.append((self.createLabel('000000'),(400,465)))
        elif self.state=='loadScreen':
            self.stateLabels.append((self.createLabel('WORLD'),(280,200)))
            self.stateLabels.append((self.createLabel('1 - 1'),(430,200)))
            self.stateLabels.append((self.createLabel('X    3'),(380,280)))
            self.playerImage=tools.get_image(setup.GRAPHICS['idle'],0,0,32,64,(0,0,0),1.5)
    def createInfoLables(self):
        self.infoLabels = []
        self.infoLabels.append((self.createLabel('GUAGUA'), (75, 30)))
        self.infoLabels.append((self.createLabel('WORLD'), (450, 30)))
        self.infoLabels.append((self.createLabel('TIME'), (625, 30)))
        self.infoLabels.append((self.createLabel('000000'), (75, 55)))
        self.infoLabels.append((self.createLabel('X00'), (300, 55)))
        self.infoLabels.append((self.createLabel('1 - 1'), (480, 55)))



    def createLabel(self,label,size=40,width_scale=0.7,height_scale=1):
            font = pygame.font.SysFont('FixedSys.ttf',size)
            label_image = font.render(label,True,C.WHITE)
            rect=label_image.get_rect()
            label_image=pygame.transform.scale(label_image,(int(rect.width*width_scale),
                                        int(rect.height*height_scale)))
            return label_image

    def update(self):
        self.flash_coin.update()

    def draw(self, surface):
        for label in self.stateLabels:
            surface.blit(label[0],label[1])
        for label in self.infoLabels:
            surface.blit(label[0],label[1])
        surface.blit(self.flash_coin.image,self.flash_coin.rect)

        if self.state=='loadScreen':
            surface.blit(self.playerImage,(300,220))
